//
//  LGTeamApplyRecordCell.m
//  BreathTrainingTool
//
//  Created by 1234 on 2024/7/15.
//

#import "LGTeamApplyRecordCell.h"
@interface LGTeamApplyRecordCell()
/**   */
@property (nonatomic , strong)UILabel *titleLabel;
/**   */
@property (nonatomic , strong)UILabel *countLabel;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *statusLabel;

@end

@implementation LGTeamApplyRecordCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.type = LGPositionTypeSingle;
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    [super setDataDic:dataDic];
    NSArray *userArray = dataDic[@"userIds"];
    self.titleLabel.text = [NSString stringWithFormat:@"申请加入%@",dataDic[@"teamName"]];
    self.countLabel.text = [NSString stringWithFormat:@"当前成员%ld个",userArray.count];
    self.timeLabel.text = LGNSString(dataDic[@"applyTime"]);
    NSString *status = LGNSString(dataDic[@"status"]);
    if ([status isEqualToString:@"0"]) {
        self.statusLabel.text = @"等待处理";
        self.statusLabel.textColor = [UIColor colorWithString:@"#796DF5"];
    }else if ([status isEqualToString:@"1"]){
        self.statusLabel.text = @"已通过";
        self.statusLabel.textColor = [UIColor colorWithString:@"#039D78"];
    }else{
        self.statusLabel.text = @"已拒绝";
        self.statusLabel.textColor = [UIColor colorWithString:@"#F93D01"];
    }
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self.baseView addSubview:self.titleLabel];
    [self.baseView addSubview:self.countLabel];
    [self.baseView addSubview:self.timeLabel];
    [self.baseView addSubview:self.statusLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.baseView).offset(viewPix(12));
        make.left.equalTo(self.baseView).offset(viewPix(16));
        make.right.equalTo(self.baseView).offset(-viewPix(16));
    }];
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(viewPix(5));
        make.left.equalTo(self.titleLabel);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.countLabel.mas_bottom).offset(viewPix(5));
        make.left.equalTo(self.titleLabel);
        make.bottom.equalTo(self.baseView).offset(-viewPix(12));
    }];
    [self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.baseView).offset(-viewPix(16));
        make.centerY.equalTo(self.countLabel);
    }];
}


-(UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [UILabel lableWithText:@"" colorString:@"#2B2A37" textFont:LGFontWeight(16, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _titleLabel;
}

-(UILabel *)countLabel{
    if(!_countLabel){
        _countLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _countLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#909399" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}

-(UILabel *)statusLabel{
    if(!_statusLabel){
        _statusLabel = [UILabel lableWithText:@"" colorString:kThemeColor textFont:LGFont(14) textAlignment:NSTextAlignmentRight lines:1];
    }
    return _statusLabel;
}

@end
